using System;

namespace Test.ConsoleProgram.Algorithm.Work
{
    [TestDescription("工作逻辑: 泛型枚举")]
    public class Test_GenericEnum : AbsBaseTestItem
    {
        public override void OnTest()
        {
            Assert.TestExe(ToInt, Type.ALL, 1);
            Assert.TestExe(ToInt, Type.B11, 4);
            Assert.TestExe(ToInt, Type.B21, 16);
        }

        [Flags]
        public enum Type
        {
            ALL = 1 << 0, // 1
            B1 = 1 << 1, // 2
            B11 = 1 << 2, // 4
            B2 = 1 << 3, // 8
            B21 = 1 << 4, // 16
            A = 1 << 5, // 32
            Customer = 1 << 6, // 64
        }
        public int ToInt<E>(E type)
        {
            if (type.GetType().IsEnum)
            {
                return Convert.ToInt32(type);
            }
            return 0;
        }
    }
}
